# -*- coding: utf-8 -*-
"""
created on 2017/12/15 15:36

@author: didichen
"""

# https://www.codewars.com/kata/sum-of-nested-numbers/

def sum_nested_numbers(arr, nest=1):
    sum = 0
    for i in arr:
        if type(i).__name__ == 'list':
            sum += sum_nested_numbers(i, nest + 1)
        else:
            sum += pow(i, nest)
    return sum


if __name__ == '__main__':
    print(sum_nested_numbers([1, [2], 3, [4, [5]]]))